package com.example.demo.thread.executor;

import com.example.demo.thread.RunnableTest;

import java.util.concurrent.*;

/**
 * @author luowj12
 * @since 2021/4/2 14:22
 */
public class TestThreadPoolExecutor {


    public static void main(String[] args) throws InterruptedException, ExecutionException {
        ExecutorService ex = new ThreadPoolExecutor(5, 8, 30, TimeUnit.SECONDS, new LinkedBlockingQueue<>(),
        new ThreadFactory(){
            @Override
            public Thread newThread(Runnable r) {
                Thread thread = new Thread(r);
                //thread.setUncaughtExceptionHandler(new MyUnchecckedExceptionhandler());
                return thread;
            }}, new ThreadPoolExecutor.CallerRunsPolicy());
        for(int i=0;i<5;i++){
            ex.submit(new RunnableTest());
            ex.execute(new RunnableTest());
        }
    }
}
